﻿using SimpleTerminal.Common;
namespace SimpleTerminal.Charset
{
    class Winucs
    {
        public const int Latin1 = 0;
        public const int VT100_Graphics = 1;
        public const int PC = 0;
        public const int USER = 0;



        public static int G0 = Latin1;
        public static int G1 = VT100_Graphics;

        private static int currentCharsetSet = 0;

        static readonly char[] UnitabXtermStd = {
            '\x2666', '\x2592', '\x2409', '\x240c', '\x240d', '\x240a', '\x00b0', '\x00b1',
            '\x2424', '\x240b', '\x2518', '\x2510', '\x250c', '\x2514', '\x253c', '\x23ba',
            '\x23bb', '\x2500', '\x23bc', '\x23bd', '\x251c', '\x2524', '\x2534', '\x252c',
            '\x2502', '\x2264', '\x2265', '\x03c0', '\x2260', '\x00a3', '\x00b7', '\x0020'
        };

        public static int CurrentCharsetSet
        {
            set
            {

                Log.Debug("CurrentCharsetSet", "设置当前字符集");
                currentCharsetSet = value;
            }
            get
            {
                return currentCharsetSet;
            }
        }

        public static char GetUcs(char cc)
        {
            switch (CurrentCharsetSet == 0 ? G0 : G1)
            {
                case Latin1:
                    return cc;
                case VT100_Graphics:
                    if (cc > '`' && cc <= '`' + 32)
                    {
                        return UnitabXtermStd[cc - '`'];
                    }
                    return cc;
            }
            return cc;
        }

    }
}
